package ljye.com.ljye.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import ljye.com.ljye.R;
import ljye.com.ljye.activity.Activity_Land;
import ljye.com.ljye.activity.Activity_My_Order;


/**
 */
public class Fragment_me extends Fragment {

    private View view;
    private LinearLayout login;
    private LinearLayout nologin;
    private LinearLayout lvMyOrderform;
    private TextView tvLogin;
    private TextView tvRegister;

    public View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.lv_my_orderform://我的订单
                    intent = new Intent(getActivity(), Activity_My_Order.class);
                    startActivity(intent);
                    break;
                case R.id.tv_login://登录
                    intent =new Intent(getActivity(), Activity_Land.class);
                    startActivity(intent);
                    break;
                case R.id.tv_register://注册

                    break;

                default:
                    break;
            }
        }
    };
    private Intent intent;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (null == view) {
            view = inflater.inflate(R.layout.fragment_me, null);

            initView();//初始化控件
        }
        lvMyOrderform.setOnClickListener(listener);
        tvLogin.setOnClickListener(listener);
        tvRegister.setOnClickListener(listener);

        return view;

    }

    private void initView() {
        login = (LinearLayout) view.findViewById(R.id.lv_my_login);
        nologin = (LinearLayout) view.findViewById(R.id.lv_my_nologin);
        tvLogin = (TextView) view.findViewById(R.id.tv_login);//登录
        tvRegister = (TextView) view.findViewById(R.id.tv_register);//注册
        lvMyOrderform = (LinearLayout)view.findViewById(R.id.lv_my_orderform);//我的订单
        //判断是否登录
        if (1==0) {
            //已登录
            login.setVisibility(View.VISIBLE);
            nologin.setVisibility(View.GONE);
        } else {
            login.setVisibility(View.GONE);
            nologin.setVisibility(View.VISIBLE);
        }


    }

}
